package com.kkagr.netty.secondExample;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;

public class Test2ServerDecoer extends LengthFieldBasedFrameDecoder {

    //这个DEVODE要结合LENGTHFILD和重新DECODE中的
    //先在的解码用的是STRINGDECODE，这个继承了MessageToMessageDecoder 的解析，这个解析是BYTE数组的解析
    private  Integer localport;
    public Test2ServerDecoer(Integer localPort) {
        super(Integer.MAX_VALUE, 0, 4, 0, 4);
        this.localport = localPort;
    }
 /*   @Override
    protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {

        ByteBuf frame = (ByteBuf) super.decode(ctx, in);
        if (frame == null) {
            return null;
        }
        int length = frame.readInt();
        byte[] msg = new byte[length];
        frame.readBytes(msg);
        // ProxyMessage proxyMessage = ProxyMessageUtil.decode(msg);
        frame.release();
        // return proxyMessage;
        return msg;
    }*/

}
